Skip to content

Add structured audit logging for admin mutation routes - #143

Merged
owens1127 merged 4 commits into
mainfrom
feat/admin-audit-logging
Jun 15, 2026
Merged

Add structured audit logging for admin mutation routes#143
owens1127 merged 4 commits into
mainfrom
feat/admin-audit-logging

Conversation

@owens1127

Copy link
Copy Markdown
Contributor

Summary

  • Introduces a reusable audit logging primitive (writeAuditLog, auditRoute, sanitizeForAudit) that emits structured ADMIN_ACTION logs via the AUDIT logger
  • Adds optional audit config to RaidHubRoute so important routes opt in without handler changes
  • Wires audit logging to admin mutations: blacklist updates, player cheat-level patches, and admin SQL queries

Each log includes actor Bungie membership ID, route, outcome, sanitized request params/body, and selected response fields — so manual UI blacklists (e.g. from PGCR menu) are traceable in Loki/Grafana even though Postgres only stores the blacklist row itself.

Test plan

  • bun test src/middleware/audit-log.test.ts
  • bun typecheck, bun lint, bun format --check locally
  • CI: Static PR Checks (tsc, lint, format, openapi verify)
  • CI: Tests + coverage

Made with Cursor

Emit ADMIN_ACTION logs with actor, request, and outcome so manual blacklist and other privileged API changes are traceable in production logs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@barecheck

barecheck Bot commented Jun 15, 2026

Copy link
Copy Markdown

Barecheck - Code coverage report

Total: 91.4%

Your code coverage diff: 0.48% ▴

Uncovered files and lines
FileLines
src/core/RaidHubRoute.ts284
src/routes/admin/query.ts94-99, 113
src/routes/admin/reporting/blacklist.ts57-95
src/routes/admin/reporting/player.ts37-55

owens1127 and others added 3 commits June 14, 2026 22:45
Co-authored-by: Cursor <cursoragent@cursor.com>
Cover writeAuditLog, sanitizeForAudit edge cases, middleware failure paths, and RaidHubRoute audit wiring.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@owens1127
owens1127 merged commit 2daf32b into main Jun 15, 2026
7 checks passed
@owens1127
owens1127 deleted the feat/admin-audit-logging branch June 15, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant